package com.coffeeloversupportlibrary.coffeelover.domain.dailyshare;

import com.coffeeloversupportlibrary.coffeelover.callback.ModelCallBack;
import com.coffeeloversupportlibrary.coffeelover.domain.dailyshare.entity.Daily;
import com.coffeeloversupportlibrary.coffeelover.domain.dailyshare.entity.Question;
import com.coffeeloversupportlibrary.coffeelover.domain.dailyshare.entity.share.DailyContent;
import com.coffeeloversupportlibrary.coffeelover.domain.dailyshare.entity.share.Share;
import com.coffeeloversupportlibrary.core.base.BaseViewModel;
import com.coffeeloversupportlibrary.core.base.livadata.SingleLiveEvent;
import com.coffeeloversupportlibrary.core.data.DataRepository;

import java.util.ArrayList;
import java.util.List;

/**
 * @author puyv
 * @createTime 2021/11/14 0:12
 * @projectName CoffeeLoverSupportLibrary
 * @className DailyShareViewModel.java
 * @description TODO
 *
 * todo:2021-11-23 19:22:17.486 2934-2934/com.coffeeloversupportlibrary E/TEST: null qu
 * 2021-11-23 19:22:21.857 2934-2934/com.coffeeloversupportlibrary E/TEST: null ques
 * 2021-11-23 19:22:29.856 2934-2934/com.coffeeloversupportlibrary E/TEST: null daily
 *
 *    Log.e("TEST","null daily");
 *    如上证明：new ? extends LiveData<T> 的时候  T t 不会被实例化
 *
 *
 *    todo: share question 部分数据使用模拟数据
 *    todo:而切换 切换 tab页面联动的效果因为无法绕开 setAdapter  --- 无法保存用户浏览状态
 *    todo: 如果使用 首页的解决方案 ---  失去 协调者布局的联动效果
 *    todo: Daily 模块使用网络数据
 *
 */
public class DailyShareViewModel extends BaseViewModel<DailyShareModel> {

    private SingleLiveEvent<List<Share>> shares=new SingleLiveEvent<>();
    private SingleLiveEvent<List<DailyContent>>  daily=new SingleLiveEvent<>();
    private SingleLiveEvent<List<Question>> questions=new SingleLiveEvent<>();

    public SingleLiveEvent<List<Share>> getShares() {
        return shares;
    }

    public SingleLiveEvent<List<DailyContent>> getDaily() {
        return daily;
    }

    public SingleLiveEvent<List<Question>> getQuestions() {
        return questions;
    }

    @Override
    protected void setModel() {
        mModel=new DailyShareModel(DataRepository.getInstance());
    }

    // TODO: 2021/11/23  供UI层调用
    public void loadDaily(){
        mModel.getShareList(new ModelCallBack<List<DailyContent>, String>() {
            @Override
            public void onSuccess(List<DailyContent> dailyContents) {
                daily.setValue(dailyContents);
            }

            @Override
            public void Failure(String s) {
                // TODO: 2021/11/24 失败发生回调 提示相应信息
            }
        });
    }



    public void loadQuestion(){
       questions.setValue(questionProvider());
    }
    public void loadShare(){
       shares.setValue(shareProvider());
    }


    private List<Daily> dataProvider(){
        List<Daily> list=new ArrayList<>();
        List<String> images=new ArrayList<>();
        images.add("https://mercury-image.oss-cn-beijing.aliyuncs.com/2021/11/08/40853e4f30a64dc095ffeb061b70b1cc1shepherd1.png");
        images.add("https://mercury-image.oss-cn-beijing.aliyuncs.com/2021/11/08/3988452377094eef814aa271047247661dlkandcoffe2.png");
        images.add("https://mercury-image.oss-cn-beijing.aliyuncs.com/2021/11/08/0c7c02fb8d574e9b88475bf9b4c560701ancientFrence3.png");
        images.add("https://mercury-image.oss-cn-beijing.aliyuncs.com/2021/11/08/40cbc416f36040f3ab41c0142df308cf1coffeeculture.jpg");

        images.add("https://mercury-image.oss-cn-beijing.aliyuncs.com/2021/11/08/40853e4f30a64dc095ffeb061b70b1cc1shepherd1.png");
        images.add("https://mercury-image.oss-cn-beijing.aliyuncs.com/2021/11/08/40853e4f30a64dc095ffeb061b70b1cc1shepherd1.png");
        images.add("https://mercury-image.oss-cn-beijing.aliyuncs.com/2021/11/08/40853e4f30a64dc095ffeb061b70b1cc1shepherd1.png");
        images.add("https://mercury-image.oss-cn-beijing.aliyuncs.com/2021/11/08/0c7c02fb8d574e9b88475bf9b4c560701ancientFrence3.png");
        images.add("https://mercury-image.oss-cn-beijing.aliyuncs.com/2021/11/08/40cbc416f36040f3ab41c0142df308cf1coffeeculture.jpg");

        List<String> image1=new ArrayList<>();
        image1.add("https://mercury-image.oss-cn-beijing.aliyuncs.com/2021/11/08/40853e4f30a64dc095ffeb061b70b1cc1shepherd1.png");
        image1.add("https://mercury-image.oss-cn-beijing.aliyuncs.com/2021/11/08/3988452377094eef814aa271047247661dlkandcoffe2.png");
        image1.add("https://mercury-image.oss-cn-beijing.aliyuncs.com/2021/11/08/0c7c02fb8d574e9b88475bf9b4c560701ancientFrence3.png");
        image1.add("https://mercury-image.oss-cn-beijing.aliyuncs.com/2021/11/08/40cbc416f36040f3ab41c0142df308cf1coffeeculture.jpg");

        Daily daily1=new Daily("咖啡圈子虽小但足够精致和深邃咖啡圈子虽小但足够精致和深邃咖啡圈子虽小但足够精致和深邃咖啡圈子虽小但足够精致和深邃咖啡圈子虽小但足够精致和" +
                "深邃咖啡圈子虽小但足够精致和深邃咖啡圈" +
                "子虽小但足够精致和深邃咖啡圈子虽小但足够" +
                "精致和深邃咖啡圈子虽小但足够精致和深邃咖啡" +
                "圈子虽小但足够精致和深邃咖啡圈子虽小但足够精致和" +
                "深邃咖啡圈子虽小但足够精致和深邃咖啡圈子虽小但足够精致和深邃咖啡圈子虽小但足够精致和深邃",image1);
        list.add(daily1);

        for(int i=0;i<3;i++){
            Daily daily=new Daily("咖啡圈子虽小但足够精致和深邃咖啡圈子虽小但足够精致和深邃咖啡圈子虽小但足够精致和深邃咖啡圈子虽小但足够精致和深邃咖啡圈子虽小但足够精致和" +
                    "深邃咖啡圈子虽小但足够精致和深邃咖啡圈" +
                    "子虽小但足够精致和深邃咖啡圈子虽小但足够" +
                    "精致和深邃咖啡圈子虽小但足够精致和深邃咖啡" +
                    "圈子虽小但足够精致和深邃咖啡圈子虽小但足够精致和" +
                    "深邃咖啡圈子虽小但足够精致和深邃咖啡圈子虽小但足够精致和深邃咖啡圈子虽小但足够精致和深邃",images);
            list.add(daily);
        }

        return list;
    }
    private List<Question> questionProvider(){
        String str1="https://mercury-image.oss-cn-beijing.aliyuncs.com/2021/11/08/3988452377094eef814aa271047247661dlkandcoffe2.png";
        String str2="https://mercury-image.oss-cn-beijing.aliyuncs.com/2021/11/08/40853e4f30a64dc095ffeb061b70b1cc1shepherd1.png";
        String str3="https://mercury-image.oss-cn-beijing.aliyuncs.com/2021/11/08/0c7c02fb8d574e9b88475bf9b4c560701ancientFrence3.png";
        String str4="https://mercury-image.oss-cn-beijing.aliyuncs.com/2021/11/08/40cbc416f36040f3ab41c0142df308cf1coffeeculture.jpg";
        List<Question> list=new ArrayList<>();

        Question question1=new Question(str1);
        Question question2=new Question(str2);
        Question question3=new Question(str3);
        Question question4=new Question(str4);
        list.add(question1);
        list.add(question2);
        list.add(question3);
        list.add(question4);

        list.addAll(list);
        list.addAll(list);


        return list;
    }
    private List<Share> shareProvider(){
        String str1="https://mercury-image.oss-cn-beijing.aliyuncs.com/2021/11/08/3988452377094eef814aa271047247661dlkandcoffe2.png";
        String str2="https://mercury-image.oss-cn-beijing.aliyuncs.com/2021/11/08/40853e4f30a64dc095ffeb061b70b1cc1shepherd1.png";
        String str3="https://mercury-image.oss-cn-beijing.aliyuncs.com/2021/11/08/0c7c02fb8d574e9b88475bf9b4c560701ancientFrence3.png";
        String str4="https://mercury-image.oss-cn-beijing.aliyuncs.com/2021/11/08/40cbc416f36040f3ab41c0142df308cf1coffeeculture.jpg";
        List<Share> list=new ArrayList<>();
        Share share1=new Share(str1,"这是较短的项目");
        Share share2=new Share(str2,"这是较长的项目这是较长的项目");
        Share share3=new Share(str3,"这是更长的项目看出来了吗 看出来了吗  看出来了吗");
        Share share4=new Share(str4,"短项目是吧");

        list.add(share1);
        list.add(share2);
        list.add(share3);
        list.add(share4);

        list.addAll(list);
        list.addAll(list);

        return list;
    }

}

